package customer_manage_function_implementation;

import java.util.LinkedList;

import customer_manage_database.Customer;


public class LookOverCustomer {
	/*
	 * 查看类，实现查看，包括有参查看和无参查看
	 */
	public void checkCustomer(String[] str,LinkedList<Customer> lList){		
		if (!(str[0].equals("")) && (str[0].substring(0,str[0].indexOf(':')).equals("name"))) {
			checkWithName(str[0].substring(str[0].indexOf(':')+1),lList);				
		}
		else {
			showAllCustomers(lList);
		}
			
	}
	//有参查看，根据name进行查找
	public void checkWithName(String name,LinkedList<Customer> lList){
		if (lList.size()!=0) {
			for (int i = 0; i < lList.size(); i++) {
				if(name.equals(lList.get(i).getName())){
					System.out.println("ID:"+lList.get(i).getID()+",name:"+
							lList.get(i).getName()+",sex:"+lList.get(i).getSex()+",birthday:"+
							lList.get(i).getBirthday()+",address:"+lList.get(i).getAddress()+
							",call:"+lList.get(i).getCall());
				}
				
			}
			
		}else {
			System.out.println("There is no customer!!!");
		}
		
	}
	//无参查看
	public void showAllCustomers(LinkedList<Customer> lList){

		if (lList.size()!=0) {
			for (int i = 0; i < lList.size(); i++) {
				System.out.println("ID:"+lList.get(i).getID()+",name:"+
					lList.get(i).getName()+",sex:"+lList.get(i).getSex()+",birthday:"+
					lList.get(i).getBirthday()+",address:"+lList.get(i).getAddress()+
					",call:"+lList.get(i).getCall());	
			}
			
		}else {
			System.out.println("There is no customer!!!");
		}
		
		
		
	}

}
